Fixed db parameter in data import#17521
Merged
CritasWang merged 4 commits intoapache:masterfrom Apr 20, 2026
Merged
Conversation
CritasWang
approved these changes
Apr 20, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves table-model import CLI behavior by refactoring how the --db option is wired into import commands and adding a database-consistency check when importing SQL files.
Changes:
- Refactors
createTableImportCommonOptions()to stop implicitly adding the database option. - Makes
--dbrequired for table CSV/TSFile imports, and explicitly adds (optional)--dbfor table SQL imports. - Adds SQL parsing logic in
ImportDataTableto detect and skip statements whose target database conflicts with the user-provided--db.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| iotdb-client/cli/src/main/java/org/apache/iotdb/tool/data/ImportDataTable.java | Adds DB extraction from SQL and enforces DB mismatch skipping during SQL import. |
| iotdb-client/cli/src/main/java/org/apache/iotdb/tool/common/OptionsUtil.java | Refactors table import option construction and makes DB required for CSV/TSFile table imports. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request makes several changes to improve database option handling and data integrity checks during table import operations in the IoTDB CLI tools. The main updates include refactoring how the database argument is added to import options and enforcing database consistency when importing SQL files.
Improvements to import option handling:
createTableImportCommonOptions()inOptionsUtil.javato no longer add the database option directly; instead, the database option is now explicitly added in each specific import method, allowing for more flexible and accurate configuration.createTableImportCsvOptions()andcreateTableImportTsFileOptions()to add the database option as a required argument, ensuring the user must specify a target database for these operations. [1] [2]createTableImportSqlOptions()to add the database option (not required), aligning behavior with the expected usage for SQL imports.Enhancements to data integrity during SQL import:
extractDbFromSql()inImportDataTable.javato extract the database name from SQL statements using a regular expression.